# -*- coding: utf-8 -*-
# @Time    : 2022/7/22 21:08
# @Author  : xhf
# @Email   : xhf9309@163.com
# @File    : handpick_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class HandpickPage(BasePage):
    '''精选页类'''
    '''定位器'''
    breakfast_locator = (By.ID,'com.gfeng.daydaycook:id/tv_breakfast')  #早餐定位器
    milk_tea_locator = (By.CLASS_NAME,'android.widget.ImageView')      #第一份早餐食谱定位器
    good_society_locator = (By.CLASS_NAME,'android.widget.ImageView')   #好物社定位器
    shopping_list_locator = (By.ID,'com.gfeng.daydaycook:id/qdLayout')  #买菜清单列表定位器


    def ele_click_breakfast(self):
        '''点击早餐'''
        self.find_element(self.breakfast_locator).click()

    def ele_click_milk_tea(self):
        '''点击第一份早餐'''
        self.find_element(self.milk_tea_locator)[2].click()

    def ele_click_good_society(self):
        '''点击好物社'''
        self.find_element(self.good_society_locator)[15].click()

    def ele_click_shopping_list(self):
        '''点击买菜清单'''
        self.find_element(self.shopping_list_locator).click()

    def ele_mine(self):
        """点击‘我的’"""
        self.driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click()

    def ele_good_thing(self):
        """点击好物社"""
        self.driver.find_element_by_android_uiautomator('new UiSelector().text("好物社")').click()

    def ele_community(self):
        """点击社区"""
        self.driver.find_element_by_android_uiautomator('new UiSelector().text("社区")').click()

    def ele_choiceness(self):
        """点击精选"""
        self.driver.find_element_by_android_uiautomator('new UiSelector().text("精选")').click()

    def func_click_milk_tea(self):
        '''点击第一份食谱'''
        self.ele_click_breakfast()
        self.ele_click_milk_tea()

    def func_click_shopping_list(self):
        '''聚合-点击买菜清单'''
        self.ele_click_shopping_list()

    def func_click_good_society(self):
        '''聚合-点击好物社'''
        self.ele_click_good_society()